package com.heima.apis.article.fallback;

import com.heima.apis.article.IArticleClient;
import com.heima.model.article.dtos.ArticleCommentDto;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.WmNewsCommentDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import org.springframework.stereotype.Component;

/**
 * feign失败配置
 */
@Component
public class IArticleClientFallback implements IArticleClient {
    @Override
    public ResponseResult save(ArticleDto articleDto) {
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR, "获取数据失败");
    }

    @Override
    public PageResponseResult findNewsComments(ArticleCommentDto dto) {
        PageResponseResult responseResult = new PageResponseResult(dto.getPage(), dto.getSize(), 0);
        responseResult.setCode(501);
        responseResult.setErrorMessage("获取数据失败");
        return responseResult;
    }

    @Override
    public ResponseResult update_comment_status(WmNewsCommentDto dto) {
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR, "获取数据失败");

    }

    @Override
    public ResponseResult newsDimension(WmNewsPageReqDto dto) {
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR, "获取数据失败");

    }

    @Override
    public PageResponseResult newsPage(WmNewsPageReqDto dto) {
        PageResponseResult responseResult = new PageResponseResult(dto.getPage(), dto.getSize(), 0);
        responseResult.setCode(501);
        responseResult.setErrorMessage("获取数据失败");
        return responseResult;
    }

    @Override
    public Boolean isComment(Long articleId) {
        return false;
    }

    @Override
    public ResponseResult newsDetail(WmNewsPageReqDto dto) {
        PageResponseResult responseResult = new PageResponseResult(dto.getPage(), dto.getSize(), 0);
        responseResult.setCode(501);
        responseResult.setErrorMessage("获取数据失败");
        return responseResult;
    }

    @Override
    public void reduceComment(Long articleId) {
        System.out.println("更新评论数量失败");
    }
}
